home *** CD-ROM | disk | FTP | other *** search
/ Czech Logic, Card & Gambling Games / Logické hry.iso / hry / Fish Fillets / script / dump / code.lua next >
Encoding:
Text File  |  2005-07-16  |  8.6 KB  |  274 lines

  1.  
  2. -- -----------------------------------------------------------------
  3. -- Init
  4. -- -----------------------------------------------------------------
  5. local function prog_init()
  6.     initModels()
  7.     sound_playMusic("music/rybky15.ogg")
  8.     local pokus = getRestartCount()
  9.  
  10.  
  11.  
  12.     -- -------------------------------------------------------------
  13.     local function prog_init_room()
  14.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  15.  
  16.         room.uvod = 0
  17.         room.obudikovi = 0
  18.         room.okramech = randint(1000, 3000)
  19.         room.olodi = 0
  20.         room.sbirka = randint(300, 1200)
  21.  
  22.         return function()
  23.             if isReady(small) and isReady(big) and no_dialog() then
  24.                 if room.okramech > 0 then
  25.                     room.okramech = room.okramech - 1
  26.                 end
  27.                 if room.sbirka > 0 then
  28.                     room.sbirka = room.sbirka - 1
  29.                 end
  30.                 if room.uvod == 0 then
  31.                     room.uvod = 1
  32.                     addm(randint(15, 30), "sm-m-prolezame")
  33.                     switch(random(3)){
  34.                         [0] = function()
  35.                             addv(random(5), "sm-v-jine0")
  36.                         end,
  37.                         [1] = function()
  38.                             addv(random(5), "sm-v-jine1")
  39.                         end,
  40.                         [2] = function()
  41.                             addv(random(5), "sm-v-jine2")
  42.                         end,
  43.                     }
  44.                 elseif room.obudikovi == 0 and look_at(small,budik) and dist(small,budik) < 3 and random(100) < 1 then
  45.                     room.obudikovi = 1
  46.                     addv(0, "sm-v-budik")
  47.                     if random(2) < 1 then
  48.                         addm(random(5), "sm-m-normalni")
  49.                     end
  50.                 elseif room.okramech == 0 then
  51.                     room.okramech = randint(1000, 3000)
  52.                     switch(random(4)){
  53.                         [0] = function()
  54.                             addm(random(10), "sm-m-kramy0")
  55.                         end,
  56.                         [1] = function()
  57.                             addm(random(10), "sm-m-kramy1")
  58.                         end,
  59.                         [2] = function()
  60.                             addv(random(10), "sm-v-kramy2")
  61.                         end,
  62.                         [3] = function()
  63.                             addv(random(10), "sm-v-kramy3")
  64.                         end,
  65.                     }
  66.                 elseif room.olodi == 0 and lod.dir ~= dir_no then
  67.                     room.olodi = 1
  68.                     switch(random(2)){
  69.                         [0] = function()
  70.                             addv(random(7), "sm-v-lod")
  71.                             addm(random(7), "sm-m-dedek")
  72.                             addv(random(7), "sm-v-charon")
  73.                             addm(random(7), "sm-m-codela")
  74.                         end,
  75.                         [1] = function()
  76.                             addv(random(7), "sm-v-charon")
  77.                             addm(random(7), "sm-m-codela")
  78.                         end,
  79.                     }
  80.                     switch(random(2)){
  81.                         [0] = function()
  82.                             addv(random(7), "sm-v-duchodce0")
  83.                         end,
  84.                         [1] = function()
  85.                             addv(random(7), "sm-v-duchodce1")
  86.                         end,
  87.                     }
  88.                 elseif room.sbirka == 0 then
  89.                     room.sbirka = -1
  90.                     addv(random(10), "sm-v-sbirka")
  91.                     addm(random(7), "sm-m-namaloval")
  92.                     if mic.beha == 1 then
  93.                         addv(random(7), "sm-v-marnost")
  94.                         addm(random(7), "sm-m-proc")
  95.                         addv(random(7), "sm-v-podivej")
  96.                         planDialogSet(random(7), "sm-x-meduza", 101, meduza, "keca")
  97.                     end
  98.                 end
  99.             end
  100.         end
  101.     end
  102.  
  103.     -- -------------------------------------------------------------
  104.     local function prog_init_meduza()
  105.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  106.  
  107.         meduza.afaze = 0
  108.         meduza.keca = 0
  109.  
  110.         return function()
  111.             if meduza.keca ~= 101 then
  112.                 if meduza.X == mic.X and meduza.Y == mic.Y - 3 then
  113.                     mic.beha = 1
  114.                     meduza.afaze = math.mod(meduza.afaze + 1, 3)
  115.                     meduza:updateAnim()
  116.                 else
  117.                     mic.beha = 0
  118.                 end
  119.             else
  120.                 mic.beha = 0
  121.             end
  122.         end
  123.     end
  124.  
  125.     -- -------------------------------------------------------------
  126.     local function prog_init_mic()
  127.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  128.  
  129.         mic.beha = 1
  130.         mic.afaze = 0
  131.  
  132.         return function()
  133.             if mic.beha == 1 then
  134.                 mic.afaze = math.mod(mic.afaze + 1, 4)
  135.                 mic:updateAnim()
  136.             end
  137.         end
  138.     end
  139.  
  140.     -- -------------------------------------------------------------
  141.     local function prog_init_meduza2()
  142.         return function()
  143.             if random(100) < 20 then
  144.                 meduza2.afaze = random(2)
  145.                 meduza2:updateAnim()
  146.             end
  147.         end
  148.     end
  149.  
  150.     -- -------------------------------------------------------------
  151.     local function prog_init_meduza1()
  152.         return function()
  153.             if random(100) < 20 then
  154.                 meduza1.afaze = random(2)
  155.                 meduza1:updateAnim()
  156.             end
  157.         end
  158.     end
  159.  
  160.     -- -------------------------------------------------------------
  161.     local function prog_init_stonozka()
  162.         return function()
  163.             if random(100) < 5 then
  164.                 stonozka.afaze = random(2)
  165.                 stonozka:updateAnim()
  166.             end
  167.         end
  168.     end
  169.  
  170.     -- -------------------------------------------------------------
  171.     local function prog_init_ostnatec()
  172.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  173.  
  174.         ostnatec.afaze = 0
  175.         ostnatec.kukuc = randint(10, 30)
  176.  
  177.         return function()
  178.             if ostnatec.kukuc > 0 and ostnatec.afaze ~= 0 then
  179.                 ostnatec.kukuc = ostnatec.kukuc - 1
  180.             elseif ostnatec.kukuc == 0 then
  181.                 ostnatec.kukuc = randint(10, 30)
  182.                 ostnatec.afaze = 0
  183.             elseif random(100) < 1 then
  184.                 ostnatec.afaze = random(2) + 1
  185.             else
  186.                 ostnatec.afaze = 0
  187.             end
  188.             ostnatec:updateAnim()
  189.         end
  190.     end
  191.  
  192.     -- -------------------------------------------------------------
  193.     local function prog_init_uhor()
  194.         return function()
  195.             if random(100) < 5 then
  196.                 uhor.afaze = random(2)
  197.                 uhor:updateAnim()
  198.             end
  199.         end
  200.     end
  201.  
  202.     -- -------------------------------------------------------------
  203.     local function prog_init_budik()
  204.         return function()
  205.             switch(math.mod(game_getCycles(), 9)){
  206.                 [0] = function()
  207.                     budik.afaze = 0
  208.                 end,
  209.                 [5] = function()
  210.                     budik.afaze = 1
  211.                 end,
  212.             }
  213.             budik:updateAnim()
  214.  
  215.             if not budik:isTalking() then
  216.                 budik:planDialog(0, "sm-x-tiktak")
  217.             end
  218.         end
  219.     end
  220.  
  221.     -- --------------------
  222.     local update_table = {}
  223.     local subinit
  224.     subinit = prog_init_room()
  225.     if subinit then
  226.         table.insert(update_table, subinit)
  227.     end
  228.     subinit = prog_init_meduza()
  229.     if subinit then
  230.         table.insert(update_table, subinit)
  231.     end
  232.     subinit = prog_init_mic()
  233.     if subinit then
  234.         table.insert(update_table, subinit)
  235.     end
  236.     subinit = prog_init_meduza2()
  237.     if subinit then
  238.         table.insert(update_table, subinit)
  239.     end
  240.     subinit = prog_init_meduza1()
  241.     if subinit then
  242.         table.insert(update_table, subinit)
  243.     end
  244.     subinit = prog_init_stonozka()
  245.     if subinit then
  246.         table.insert(update_table, subinit)
  247.     end
  248.     subinit = prog_init_ostnatec()
  249.     if subinit then
  250.         table.insert(update_table, subinit)
  251.     end
  252.     subinit = prog_init_uhor()
  253.     if subinit then
  254.         table.insert(update_table, subinit)
  255.     end
  256.     subinit = prog_init_budik()
  257.     if subinit then
  258.         table.insert(update_table, subinit)
  259.     end
  260.     return update_table
  261. end
  262. local update_table = prog_init()
  263.  
  264.  
  265. -- -----------------------------------------------------------------
  266. -- Update
  267. -- -----------------------------------------------------------------
  268. function prog_update()
  269.     for key, subupdate in pairs(update_table) do
  270.         subupdate()
  271.     end
  272. end
  273.  
  274.